#define _CRT_SECURE_NO_WARNINGS 1
int GetNumberOfK(int* data, int dataLen, int k) {
    // write code here
    scanf("%d", &k);
    int right = dataLen - 1;
    int left = 0;
    int count = 0;
    int ret = 0;
    while (left <= right)
    {
        int mid = (left + right) / 2;
        if (data[mid] < k)
        {
            left = mid + 1;
        }
        else if (data[mid] > k)
        {
            right = mid - 1;
        }
        else
        {
            while (1)
            {
                if (mid >= 0 && data[mid] == k)
                {
                    count++;
                    mid--;
                }
                else
                {
                    mid += count + 1;
                    break;
                }
            }
            while (mid < dataLen && data[mid] == k)
            {
                if (mid < dataLen && data[mid] == k)
                {
                    count++;
                    mid++;
                }
                else
                    break;
            }
            break;
        }
    }
    return count;
}